<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      >
    <body>
    
        <ui:composition template="./../noLogin/myTemplate2.xhtml">
            <ui:define name="content">

                <h1><h:outputLabel value="#{msgs.schools}:#{msgs.pinyin}#{msgs.order}"/></h1>
                <h:messages   style="color: red" id="latestMessage"/>


                <table rendered="#{schoolBean.nameofunitList.size()>0}" border="1">
                    <tr>
                        <th>#{msgs.schoolNum}</th>
                        <th>#{msgs.schoolName}</th>
                        <th>#{msgs.school}#{msgs.pinyin}#{msgs.firstChar}</th>
                        <th>#{msgs.cate}</th>
                        <th>#{msgs.unit}</th>
                        <th>#{msgs.alter}</th>
                        <th>#{msgs.delete}</th>
                    </tr>
                    <c:forEach items="#{schoolBean.nameofunitList}" var="school">
                        <h:form>
                            <tr>
                                <td><h:outputLabel value="#{school.id}"/></td>
                                <td><h:inputText value="#{school.name}"/></td>
                                <td><h:inputText value="#{school.pinyin}" /></td>
                                <td><h:selectOneMenu value="#{school.mytype}">
                                        <f:selectItems  value="#{schoolBean.mytypeMap}"/>
                                    </h:selectOneMenu></td>
                                <td><h:outputLabel value="#{school.parNameofunit.name}"/></td>
                                <td>
                                    <h:commandButton value="#{msgs.alter}" action="#{schoolBean.alterSchool(school.id,school.name,school.pinyin,school.mytype)}" />
                                </td>
                                <td>
                                    <h:commandButton value="#{msgs.delete}" action="#{schoolBean.deleteSchool()}">
                                        <f:param value="#{school.id}" name="schoolId"/>
                                    </h:commandButton>
                                </td>
                            </tr>
                        </h:form>
                    </c:forEach>
                </table>


                <h:form>
                    <h:panelGrid>
                        <h1><h:outputLabel value="#{msgs.addSchool}"/></h1>
                        <h:panelGrid columns="2">
                            <h:outputLabel value="#{msgs.schoolNum}" />
                            <h:inputText value="#{schoolBean.schoolId}" required="true"/>
                            <h:outputLabel value="#{msgs.schoolName}" />
                            <h:inputText value="#{schoolBean.schoolName}" required="true"/>
                            <h:outputLabel value="#{msgs.school}#{msgs.pinyin}#{msgs.firstChar}" />
                            <h:inputText value="#{schoolBean.pinyin}" required="true"/>
                            <h:outputLabel value="#{msgs.cate}" />
                            <h:selectOneMenu value="#{schoolBean.mytype}">
                                <f:selectItems  value="#{schoolBean.mytypeMap}"/>
                            </h:selectOneMenu>
                            <h:commandButton action="#{schoolBean.addSchool()}" value="#{msgs.add}"/>
                        </h:panelGrid>
                    </h:panelGrid>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
